package com.nhncorp.ntaf;

import java.util.Calendar;

import fit.FitServer;
import fit.Parse;

/**
 * @author nhn
 * @version 1.0
 * @created 04-8-2008 PM 5:40:12
 */
public class FlowFixture extends NtafSequenceFixture {

	public void doTable(Parse table) {
		this.interpretTables(table);
	}
	
	public boolean assertNotEquals(final String expected, final String actual) {
		return !assertEquals(expected, actual);
	}
	
	public boolean assertEquals(final String expected, final String actual) {
		boolean result = false;
		
		if (NtafInfo.isNumberCompare(expected, actual)) {
			final double actualNumber = NtafInfo.castingNumber(actual);
			final double expectedNumber = NtafInfo.castingNumber(expected);

			if (NtafInfo.isSameDouble(expectedNumber, actualNumber)) {
				result = true;
			} else {
				result = false;
			}
		} else if (expected.equals(actual)) {
			result = true;
		} 
		
		return result;
	}

	public boolean assertTrue(String condition) {
		NtafInfo ntafInfo = new NtafInfo();
		return ntafInfo.checkCondition(condition);
	}
	
	public boolean assertFalse(String condition) {
		return !assertTrue(condition);
	}
	
	public void setStartTime(String startTime){
		FitServer.setSymbol(startTime, Calendar.getInstance().getTimeInMillis());				
	}
	
	public void setDuration(String startTime, String duration){
		long now = Calendar.getInstance().getTimeInMillis();
		long start = Long.valueOf(startTime);
		
		FitServer.setSymbol(duration, now - start);				
	}
	
	public static void clearSymbols() {
		FitServer.ClearSymbols();
	}
}